package com.example.pc.greenplants.Personal;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.example.pc.greenplants.Community.Shequ_dl;
import com.example.pc.greenplants.First.Main2Activity;
import com.example.pc.greenplants.R;

import java.util.ArrayList;
import java.util.List;

import cn.bmob.v3.BmobUser;

public class Personal extends AppCompatActivity {

    private TextView bexit;
    private String name;
    private int imageId;
    private TextView uname;

    private List<Personal> personalList=new ArrayList<>();
    private static final String TAG = "Personal";
    private ListView listView;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personal);
        Button btn1 =(Button) findViewById(R.id.button1);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Personal.this, Main2Activity.class);
                startActivity(intent);
            }
        });
        Button btn2 =(Button) findViewById(R.id.button2);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Personal.this, Shequ_dl.class);
                startActivityForResult(intent,1);
            }
        });
        bexit = (TextView)findViewById(R.id.exit);
        bexit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                BmobUser.logOut();
                Intent intent = new Intent(Personal.this, WDL.class);
                startActivity(intent);
            }
        });

        uname = findViewById(R.id.personal_name);
        uname.setText("用户名:" + BmobUser.getCurrentUser().getUsername());

        initPersonals();
        PersonalAdapter adapter = new PersonalAdapter(Personal.this,R.layout.activity_personal,  personalList);
        Log.e(TAG, "onCreate: "+ adapter.toString() );
    }

  public Personal(String name,int imageId){
      this.name=name;
      this.imageId=imageId;
  }

  public Personal() {}


    public String getName() {
        return name;
    }

    public int getImageId() {
        return imageId;
    }


    private  void initPersonals(){
        Personal shoucang=new Personal(" 收藏",R.drawable.shoucang);
        personalList.add(shoucang);
        Personal xiangce=new Personal("相册",R.drawable.zhaopian);
        personalList.add(xiangce);
        Personal fenxiang=new Personal("分享",R.drawable.fenxiang);
        personalList.add(fenxiang);
        Personal qianbao=new Personal("钱包",R.drawable.qianbao);
        personalList.add(qianbao);
        Personal shezhi=new Personal("设置",R.drawable.shezhi);
        personalList.add(shezhi);
    }
}
